package org.lanqiao.tjut.controller;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * 原生态的 AjaxDemoServlet
 */
@WebServlet("/AjaxDemoServlet")
public class AjaxDemoServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;

	protected void service(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		// 获取客户端发送的请求数据
		String strName = request.getParameter("txtName");
		String strAge = request.getParameter("txtAge");
		System.out.println("客户端数据：Name=" + strName + ";Age=" + strAge);
		// 使用writer对象将服务器响应内容写到客户端
		PrintWriter pw = response.getWriter();
		pw.write("服务端响应了");
		pw.flush();
		pw.close();
	}

}
